package top.hiai.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import top.hiai.common.result.JsonResult;
import top.hiai.common.utils.GetLoginUser;
import top.hiai.service.UserService;
import top.hiai.service.vo.KeUserSubimtVo;

/**
 * @Author hkq
 * @Email goodsking@163.com
 */
@Controller
@RestController
@Api(tags = "APP端：用户管理")
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "用户登录授权")
    @PostMapping("/auth")
    public JsonResult getHotCourse(@RequestBody KeUserSubimtVo userSubimtVo)throws Exception {
        return userService.userAuth(userSubimtVo.getOpenid());
    }

    @ApiOperation(value = "登录用户信息")
    @GetMapping("/get_login")
    public JsonResult getLogin(){
        Integer userId = GetLoginUser.getLoginUser();
        return JsonResult.succ( userService.getUserById(userId));
    }

    @ApiOperation(value = "获取用户使用天数")
    @GetMapping("/get_info")
    public JsonResult getUserInfo(){
        Integer userId = GetLoginUser.getLoginUser();
        return JsonResult.succ( userService.getUserInfo(userId));
    }
}
